/**
 * Created on 4 oct. 2006 -- 13:39:10
 * Author: avezier (Inovatel)
 */
package antoine.ear.exo.intervalles;

import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.Sequence;
import javax.sound.midi.Track;

import antoine.ear.exo.Exo;
import antoine.ear.generator.NoteGenerator;

public class NeuviemeMUp  extends Exo {

    public NeuviemeMUp(int tempo, int octave) {
        super(tempo, octave);
    }

    public String getPrintableResult() {
        return null;
    }

    public void generate() throws Exception {
        try {
            Sequence seq = new Sequence(Sequence.PPQ, 1);
            int tick;
            for (int i=0; i<30; i++){
                tick = i*4;
                Track track = seq.createTrack();
                int note = NoteGenerator.generateNote(this.getOctave());
                track.add(createNoteOnEvent(note, tick));
                track.add(createNoteOffEvent(note, tick+1));
                track.add(createMetaMessOnEvent(note, tick, ACTIVATENOTE));
                track.add(createMetaMessOnEvent(note, tick+1, DESACTIVATENOTE));
                
                track.add(createNoteOnEvent(note+14, tick+1));
                track.add(createNoteOffEvent(note+14, tick+2));
                track.add(createMetaMessOnEvent(note+14, tick+1, ACTIVATENOTE));
                track.add(createMetaMessOnEvent(note+14, tick+2, DESACTIVATENOTE));
                
                track.add(createNoteOnEvent(note, tick+2));
                track.add(createNoteOnEvent(note+14, tick+2));
                track.add(createNoteOffEvent(note, tick+3));
                track.add(createNoteOffEvent(note+14, tick+3));
                track.add(createMetaMessOnEvent(note+14, tick+2, ACTIVATENOTE));
                track.add(createMetaMessOnEvent(note, tick+2, ACTIVATENOTE));
                track.add(createMetaMessOnEvent(note+14, tick+3, DESACTIVATENOTE));
                track.add(createMetaMessOnEvent(note, tick+3, DESACTIVATENOTE));
            }
            this.setSequence(seq);
            setTempo(tempo);
        } catch (InvalidMidiDataException e) {
            throw new Exception(e); 
        }
    }

    public String getIndication() {
        return "no indication";
    }
}
